package cn.mastor.service.impl;

import cn.mastor.domain.Msg;
import cn.mastor.mapper.MsgMapper;
import cn.mastor.netty.ChatMsg;
import cn.mastor.service.IMsgService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author whale
 * @since 2022-12-09
 */
@Service
public class MsgServiceImpl extends ServiceImpl<MsgMapper, Msg> implements IMsgService {

    @Override
    public Integer save(ChatMsg chatMsg) {
        Msg msg = new Msg();
        msg.setSenderId(chatMsg.getSenderId());
        msg.setReceiverId(chatMsg.getSenderId());
        msg.setType(0);
        msg.setMsg(chatMsg.getMsg());
        msg.setTime(new Date());
        insert(msg);
        return msg.getId();
    }
}
